﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KingSite.SyncDB.Repository;
using System.Data;
using System.Data.SqlClient;
using System.Threading;
using KingSite.SyncDB.Core.Repository;
using KingSite.SyncDB.Core.Entity;

namespace KingSite.SyncDB {
    public class SyncJobDetail {
        SyncRepository sr = new SyncRepository();
        private SyncJobInfo job;
        public SyncJobDetail(SyncJobInfo job) {
            this.job = job;
        }

        /// <summary>
        /// 运行任务
        /// </summary>
        public void RunJob() {
            while (true) {
                Console.WriteLine("任务:" + job.JobName + "开始运行...");
                IList<SyncEntity> list = sr.GetSyncEntityList(job);
                AbstractDataAccess ada = DataAccessFactory.GetDataAccess(job, list);
                ada.ExecSyncJob();                
                Console.WriteLine("任务:" + job.JobName + "结束 ");
            }
        }

    }
}
